




function win() {
	return Math.floor(Math.random() * 2) % 2 == 1;
}


let coin = 10000;

let c = 1;

let count = {
	win: 0,
	defeat: 0
};

for (let i = 0; i < 1000000; i++) {
	let hasWin = win();
	let cc = c;
	if (hasWin) {
		coin += c;
		c = 1;
		// c /= 2;
		// c = Math.round(c);
		count.win++;
	} else {
		coin -= c;
		c *= 2;
		if (c >= coin) c = 1;
		count.defeat++;
	}
	console.log(i + 1 + "\t" + (hasWin ? "赢" : "输") + cc + "\t" + coin);

	if (coin <= 0) break;
}

console.log(count.win + "\t" + count.defeat);